package com.yq.cp.service.data.impl;

import cn.afterturn.easypoi.cache.manager.IFileLoader;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yq.cp.entity.basics.EquipmentManagement;
import com.yq.cp.entity.basics.OrganizationalStructure;
import com.yq.cp.entity.common.PageVo;
import com.yq.cp.entity.data.CoefficientYear;
import com.yq.cp.entity.data.NengKongDataDay;
import com.yq.cp.entity.data.VideoSurveillance;
import com.yq.cp.entity.data.dto.NyzfdqkDto;
import com.yq.cp.entity.data.vo.IndexGfVo;
import com.yq.cp.entity.manage.EnergyStation;
import com.yq.cp.entity.manage.OpsTicketsMessage;
import com.yq.cp.mapper.basics.EquipmentManagementMapper;
import com.yq.cp.mapper.basics.OrganizationalStructureMapper;
import com.yq.cp.mapper.data.CoefficientYearMapper;
import com.yq.cp.mapper.data.NengKongDataDayMapper;
import com.yq.cp.mapper.data.VideoSurveillanceMapper;
import com.yq.cp.mapper.manage.EnergyMacMapper;
import com.yq.cp.mapper.manage.EnergyStationMapper;
import com.yq.cp.mapper.manage.OpsTicketsMessageMapper;
import com.yq.cp.service.basics.OrganizationalStructureService;
import com.yq.cp.service.data.IndexGfService;
import com.yq.cp.utils.DateTimeUtil;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Transactional
public class IndexGfServiceImpl implements IndexGfService {

    @Resource
    private NengKongDataDayMapper dataDayMapper;
    @Resource
    OrganizationalStructureMapper organizationalStructureMapper;
    @Resource
    OrganizationalStructureService organizationalStructureService;
    @Resource
    private OpsTicketsMessageMapper opsTicketsMessageMapper;
    @Resource
    private EquipmentManagementMapper equipmentManagementMapper;

    @Resource
    VideoSurveillanceMapper videoSurveillanceMapper;
    @Resource
    CoefficientYearMapper coefficientYearMapper;
    @Override
    public Map<String, Object> query1(NengKongDataDay n) {
        Map<String, Object> map=new HashMap<>();


        QueryWrapper<OrganizationalStructure> organizationalStructureQueryWrapper=new QueryWrapper<>();
        organizationalStructureQueryWrapper.eq("examine",1);
        organizationalStructureQueryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(organizationalStructureQueryWrapper);

        BigDecimal a102=new BigDecimal(0);
        BigDecimal a101=new BigDecimal(0);
        BigDecimal a105=new BigDecimal(0);
        BigDecimal a106=new BigDecimal(0);
        BigDecimal a107=new BigDecimal(0);
        for (int k = 0; k < energyStations.size(); k++) {
            OrganizationalStructure organizationalStructure = energyStations.get(k);

            n.setId(organizationalStructure.getId());
            Long nyzId = organizationalStructure.getId();

            BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
            n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
            //发电功率 107
            n.setType(107);
            n.setClassifyNumber(2);
            newest = dataDayMapper.qxdqgl(nyzId);//dataDayMapper.newest(n);
            map.put("a100",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"kW");

            //当日发电量 109-发电量（每小时）
            n.setType(115);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
            BigDecimal qxzxz = dataDayMapper.qxzxz1(nyzId,DateTimeUtil.getStrDateTime3(new Date()),115);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            newest=newest.subtract(qxzxz);
            newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
            BigDecimal dr=newest;
            map.put("a109",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");

            //累计发电量  101-发电量（当日）
            qxzxz = dataDayMapper.qxzxz31(nyzId, 119,n.getYear(),n.getMonth());
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            BigDecimal qxzdz = dataDayMapper.qxzdz31(nyzId,119,n.getYear(),n.getMonth());
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            BigDecimal bigDecimal1 = qxzdz.subtract(qxzxz);

            a101=a101.add(bigDecimal1);
//            map.put("a101",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)
            //总装机
            n.setType(102);
            n.setClassifyNumber(1);
//            newest = dataDayMapper.zj(n);
//            newest=newest==null?new BigDecimal(0.00):newest;
            BigDecimal installedCapacity = organizationalStructure.getInstalledCapacity();
            installedCapacity=installedCapacity==null?new BigDecimal(0):installedCapacity;
            a102=a102.add(installedCapacity);
//            map.put("a102",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"");//+"kW"

            if(n.getYear()==null){

                QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
                queryWrapper22.ge("year",2024);
                List<CoefficientYear> coefficientYears = coefficientYearMapper.selectList(queryWrapper22);
                bigDecimal1=new BigDecimal(0);
                BigDecimal bigDecimal2=new BigDecimal(0);
                for (int i = 0; i < coefficientYears.size(); i++) {
                    CoefficientYear coefficientYear1 = coefficientYears.get(i);
                    qxzxz = dataDayMapper.qxzxz31(nyzId, 119,coefficientYear1.getYear(),n.getMonth());
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    qxzdz = dataDayMapper.qxzdz31(nyzId,119,coefficientYear1.getYear(),n.getMonth());
                    qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
                    bigDecimal1 = bigDecimal1.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient1()));
                    bigDecimal2 = bigDecimal2.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient2()));
                }


                //节煤炭量
//                map.put("a105",bigDecimal1.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
                //碳减排量
//                map.put("a106",bigDecimal2.divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
                //植树
//                map.put("a107",bigDecimal2.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

                a105=a105.add(bigDecimal1);
                a106=a106.add(bigDecimal2);
                a107=a107.add(bigDecimal2);
            }else {
                QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
                queryWrapper22.eq("year",n.getYear());
                CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
                //节煤炭量
//                map.put("a105",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
                //碳减排量
//                map.put("a106",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
                //植树
//                map.put("a107",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*18.3*40),0, RoundingMode.HALF_UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

                a105=a105.add(bigDecimal1.multiply(coefficientYear.getCoefficient1()));
                a106=a106.add(bigDecimal1.multiply(coefficientYear.getCoefficient2()));
                a107=a107.add(bigDecimal1.multiply(coefficientYear.getCoefficient2()));


            }
            //光伏电站数量 001
            QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("examine",1);
            queryWrapper.eq("type",6);
            Long aLong = organizationalStructureMapper.selectCount(queryWrapper);
            map.put("a001",(aLong==null?0:aLong));

            //运行天数 002
            n.setType(101);
            n.setClassifyNumber(1);
            Long yxts = dataDayMapper.yxts(n);
            map.put("a002",(yxts==null?"0.00":yxts));
        }
        map.put("a102",a102.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW"
        map.put("a101",a101.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW"
        map.put("a105",a105.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a106",a106.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a107",a107.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.HALF_UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");


        return map;
    }
    @Override
    public Map<String, Object> query11(NengKongDataDay n) {

        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        if (n.getEnergyId()!=null){
            queryWrapper.eq("id",n.getEnergyId());
        }
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        Map<String, Object> map=new HashMap<>();
        BigDecimal a11=new BigDecimal(0);
        BigDecimal a22=new BigDecimal(0);
        BigDecimal b11=new BigDecimal(0);
        BigDecimal b22=new BigDecimal(0);
        BigDecimal c11=new BigDecimal(0);
        BigDecimal c22=new BigDecimal(0);
        for (int i = 0; i < energyStations.size(); i++) {
            BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);

            Long id = energyStations.get(i).getId();
            n.setId(id);
            n.setEnergyId(id);
            n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));


            //上网电量
            n.setType(115);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
            BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),115);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            newest=newest.subtract(qxzxz);
            newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
            BigDecimal dr=newest;
            BigDecimal c1=newest;
//            map.put("c1",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            c11=c11.add(newest);
            //总上网电量

            qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 115,n.getYear(),n.getMonth());
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            BigDecimal qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),115,n.getYear(),n.getMonth());
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            BigDecimal bigDecimal1 = qxzdz;
            BigDecimal c2=bigDecimal1.subtract(qxzxz);
//            map.put("c2",bigDecimal1.subtract(qxzxz).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)
            c22=c22.add(bigDecimal1.subtract(qxzxz));

            //消网电量
            n.setType(116);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
            qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),116);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            newest=newest.subtract(qxzxz);
            newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
            dr=newest;
            BigDecimal a1=newest;
//        map.put("c1",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");
            //总消网电量

            qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 116,n.getYear(),n.getMonth());
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;

            qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),116,n.getYear(),n.getMonth());
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            bigDecimal1 = qxzdz.subtract(qxzxz);
            BigDecimal a2=bigDecimal1;
//        map.put("c2",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP));//+"kW·h" .divide(new BigDecimal(10000)
//            map.put("b1",dr.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
//            map.put("b2",bigDecimal1.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)

            b11=b11.add(dr);
            b22=b22.add(bigDecimal1);

            //发电量
            n.setType(119);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
            qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),119);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            newest=newest.subtract(qxzxz);
            newest=newest.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
            dr=newest;
//        map.put("c1",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"kWh");
            //总发电量

            qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 119,n.getYear(),n.getMonth());
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),119,n.getYear(),n.getMonth());
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            bigDecimal1 = qxzdz.subtract(qxzxz);
//        map.put("c2",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP));//+"kW·h" .divide(new BigDecimal(10000)
//            map.put("a1",dr.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
//            map.put("a2",bigDecimal1.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)
            a11=a11.add(dr);
            a22=a22.add(bigDecimal1);
        }

        map.put("a1",a11.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a2",a22.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("b1",b11.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("b2",b22.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("c1",c11.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("c2",c22.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        return map;
    }
    @Override
    public Map<String, Object> query2(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(109);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//                    if (nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                        list2.add(nengKongDataDay.getValue());
//                    }else {
//                        BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//                        list2.add(nengKongDataDay.getValue().subtract(qxzxz));
//                    }

                }else {
                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                        value=nengKongDataDay.getValue();

                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),109,nengKongDataDay.getV());
                    }
                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    }
                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    //当日发电量 109-发电量（每小时）
                    n.setType(109);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    //当日发电量 109-发电量（每小时）
                    n.setType(109);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);

                    BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    //当日发电量 109-发电量（每小时）
                    n.setType(109);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }
        return map;
    }

    @Override
    public Map<String, Object> query251(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int month = DateTimeUtil.getMonth(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int day = DateTimeUtil.getDay(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));

            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(115);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                list2.add(nengKongDataDay.getValue1().setScale(2, BigDecimal.ROUND_HALF_UP));
//                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//
//
//                }else {
//                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
//                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//
//                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),115,nengKongDataDay.getV());
//                    }
//                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
//                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
//                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    }
//                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
//                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(115);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(115);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(115);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

//                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(115);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    //当日发电量 109-发电量（每小时）
                    n.setType(115);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        } else if (indexGfVo.getTypeNumber()==5) {
            indexGfVo.setType(115);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query26(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> query252(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int month = DateTimeUtil.getMonth(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int day = DateTimeUtil.getDay(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(117);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                list2.add(nengKongDataDay.getValue1().setScale(2, BigDecimal.ROUND_HALF_UP));
//                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//
//
//                }else {
//                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
//                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),117,nengKongDataDay.getV());
//                    }
//                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
//                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
//                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    }
//                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
//                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(117);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(117);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(117);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

//                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
////                    NengKongDataDay n=new NengKongDataDay();
////                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
////                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
////                    //当日发电量 109-发电量（每小时）
////                    n.setType(117);
////                    n.setClassifyNumber(2);
////                    newest = dataDayMapper.newest(n);
////
////                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
////                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
////                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);
////
////                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(119);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(117);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),117);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        } else if (indexGfVo.getTypeNumber()==5) {
            indexGfVo.setType(117);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query26(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> query253(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int month = DateTimeUtil.getMonth(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int day = DateTimeUtil.getDay(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(116);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);

                list1.add(nengKongDataDay.getV());
                list2.add(nengKongDataDay.getValue1().setScale(2, BigDecimal.ROUND_HALF_UP));
//                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//
//
//                }else {
//                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
//                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//
//                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),116,nengKongDataDay.getV());
//                    }
//                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
//                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
//                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    }
//                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
//                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(116);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(116);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(116);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

//                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(116);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(116);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),116);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        } else if (indexGfVo.getTypeNumber()==5) {
            indexGfVo.setType(116);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query26(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }

    @Override
    public Map<String, Object> query256(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        if (indexGfVo.getTypeNumber()==2){
            List<BigDecimal> cxdxxss = dataDayMapper.cxdxxss(indexGfVo.getId(), DateTimeUtil.getYear(), DateTimeUtil.getMonth());
            map.put("list2",cxdxxss);
        }else if (indexGfVo.getTypeNumber()==3){

            List<BigDecimal> cxdxxss = dataDayMapper.cxdxxss1(indexGfVo.getId(), DateTimeUtil.getYear());
            map.put("list2",cxdxxss);
        }else if (indexGfVo.getTypeNumber()==5){

            List<BigDecimal> cxdxxss = dataDayMapper.cxdxxss2(indexGfVo.getId());
            map.put("list2",cxdxxss);
        }
        return map;
    }
    @Override
    public Map<String, Object> query255(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int month = DateTimeUtil.getMonth(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int day = DateTimeUtil.getDay(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);

                list1.add(nengKongDataDay.getV());
                list2.add(nengKongDataDay.getValue1().setScale(2, BigDecimal.ROUND_HALF_UP));
//                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//
//
//                }else {
//                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
//                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),119,nengKongDataDay.getV());
//                    }
//                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
//                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
//                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    }
//                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
//                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//
//
//                        n.setType(119);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            indexGfVo.setType(119);
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

//                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
//                    List<OrganizationalStructure> zsnyz = organizationalStructureService.zsnyz();
//
//                    BigDecimal val=new BigDecimal(0);
//                    for (int k = 0; k < zsnyz.size(); k++) {
//                        OrganizationalStructure organizationalStructure = zsnyz.get(k);
//                        NengKongDataDay n=new NengKongDataDay();
//                        n.setId(organizationalStructure.getId());
//                        n.setEnergyId(organizationalStructure.getId());
//
//                        n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                        //当日发电量 109-发电量（每小时）
//                        n.setType(119);
//                        n.setClassifyNumber(2);
//                        newest = dataDayMapper.newest(n);
//                        newest=newest == null ? new BigDecimal(0.00):newest;
//                        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                        qxzxz=qxzxz==null?new BigDecimal(0.00):qxzxz;
//                        BigDecimal subtract = newest.subtract(qxzxz);
//
//                        subtract=subtract.compareTo(new BigDecimal(0.00))==-1?new BigDecimal(0.00):subtract;
//                        val=val.add(subtract);
//
//                    }
//                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(val));
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(119);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz1(indexGfVo.getEnergyId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        } else if (indexGfVo.getTypeNumber()==5) {
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query26(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }


    @Override
    public Map<String, Object> query254(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();


        int year1 = DateTimeUtil.getYear(indexGfVo.getRq());
        int month1 = DateTimeUtil.getMonth(indexGfVo.getRq());
        int day1 = DateTimeUtil.getDay(indexGfVo.getRq());

        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int month = DateTimeUtil.getMonth(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));
            int day = DateTimeUtil.getDay(DateTimeUtil.toSimpleDate(indexGfVo.getEndTime()));


            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(119);
            if (indexGfVo.getMacId()==null){
                indexGfVo.setMacId(-999l);
            }
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());


                if (year1==year && month1==month && day1==day ){
                    String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00:00";
                    Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
                    if(simpleDateTime.after(DateTimeUtil.dqsj())){
                        list2.add("");
                        continue;
                    }
                }
                list2.add(nengKongDataDay.getValue1());
//                if (i==0 || nengKongDataDay.getValue().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//                }else {
//                    BigDecimal value = nengKongDataDays.get(i - 1).getValue();
//                    if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//
//                        value=dataDayMapper.qxzxz19(indexGfVo.getEnergyId(),DateTimeUtil.getStrDateTime3(new Date()),119,nengKongDataDay.getV());
//                    }
//                    value=value==null?new BigDecimal(0):value;
//                    BigDecimal subtract = nengKongDataDay.getValue().subtract(value);
//                    if (subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<0){
//                        subtract=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    }
//                    list2.add(subtract.setScale(2, BigDecimal.ROUND_HALF_UP));
//                }
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());


                if (year1==year && month1==month && nengKongDataDay.getV()>day){
                    list2.add("");
                    continue;
                }

//                if (nengKongDataDay.getV()==DateTimeUtil.getDay()){
//                    NengKongDataDay n=new NengKongDataDay();
//                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    //当日发电量 109-发电量（每小时）
//                    n.setType(119);
//                    n.setClassifyNumber(2);
//                    n.setMacId(indexGfVo.getMacId());
//                    newest = dataDayMapper.newest(n);
//                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);
//
//                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
//
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==3){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (year1==year && nengKongDataDay.getV()>month){
                    list2.add("");
                    continue;
                }

//                if (nengKongDataDay.getV()==DateTimeUtil.getMonth()){
//                    NengKongDataDay n=new NengKongDataDay();
//                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    //当日发电量 109-发电量（每小时）
//                    n.setType(119);
//                    n.setClassifyNumber(2);
//                    n.setMacId(indexGfVo.getMacId());
//                    newest = dataDayMapper.newest(n);
//
//                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
//                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
//                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);
//
//                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);
//                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if(indexGfVo.getTypeNumber()==4){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query23(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                if (nengKongDataDay.getD().equals(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(119);
                    n.setClassifyNumber(2);
                    n.setMacId(indexGfVo.getMacId());
                    newest = dataDayMapper.newest(n);
                    BigDecimal qxzxz = dataDayMapper.qxzxz122(indexGfVo.getEnergyId(),indexGfVo.getMacId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
                    qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                    BigDecimal subtract = nengKongDataDay.getValue().add(newest == null ? new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP) : newest).subtract(qxzxz);

                    nengKongDataDay.setValue(subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract);

                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }else if (indexGfVo.getTypeNumber()==5) {
            indexGfVo.setType(119);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query26(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getD());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
        }
        return map;
    }

    public Map<String, Object> query30(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<String> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();

            int year = DateTimeUtil.getYear(indexGfVo.getTime());
            int month = DateTimeUtil.getMonth(indexGfVo.getTime());
            int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(indexGfVo.getType());
            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
            }

            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20111(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                Integer v1 = nengKongDataDay.getV();
                Integer m1 = nengKongDataDay.getMinuteNumber();
                if (i<nengKongDataDays.size()-1){
                    NengKongDataDay n2 = nengKongDataDays.get(i+1);
                    Integer v2 = n2.getV();
                    Integer m2 = n2.getMinuteNumber();
                    Integer a=0;
                    while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                        if (m1<10){
                            list1.add(v1+":0"+m1);
                        }else {
                            list1.add(v1+":"+m1);
                        }
                        m1=m1+1;
//                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));//
                        if (i!=0){
                            NengKongDataDay na = nengKongDataDays.get(i-1);
                            BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                            list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                        }
                        a++;
                        if (m1==60){
                            m1=0;
                            v1++;
                        }
                    }
                    if (a==0){
                        if (m1<10){
                            if (m1>0 && m1<5){
                                list1.add(v1+":00");
                            }else {
                                list1.add(v1+":0"+m1);
                            }
                        }else {
                            list1.add(v1+":"+m1);
                        }
                        if (i!=0){
                            NengKongDataDay na = nengKongDataDays.get(i-1);
                            BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                            list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                        }

                    }

                }else {
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }

                }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {
            if (i%5!=0){
                continue;
            }
            if (list1.get(i).equals("11:55")){
                System.out.println(123);
            }
            BigDecimal value = list2.get(i);
            if (i==0){
                value=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);//value.divide(new BigDecimal(5*60),2);
            }else {
                BigDecimal value1 = list2.get(i-5);
                BigDecimal subtract = value.subtract(value1);
                subtract=subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract;
                subtract=subtract.multiply(new BigDecimal(1000));
                value=subtract.divide(new BigDecimal(5*60),2);
            }

            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
//                String s = list1.get(i);
//                String[] split = s.split(":");
//                int i1 = Integer.parseInt(split[0]);
//                int i2 = Integer.parseInt(split[1]);
//                Integer hour = DateTimeUtil.getHour();
//                Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());
//                if (((i1==hour && i2>minute) || (i1<hour )) && i1>8 && value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    value=null;
//                }
                if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
                    value=null;
                }
            }


            list11.add(list1.get(i));
            list22.add(value);
            A++;
        }
            map.put("list1",list11);
            map.put("list2",list22);

        return map;
    }

    @Override
    public Map<String, Object> query3(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<String> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();
        Integer hour = DateTimeUtil.getHour();
        Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());

        int year = DateTimeUtil.getYear(indexGfVo.getTime());
        int month = DateTimeUtil.getMonth(indexGfVo.getTime());
        int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
        indexGfVo.setYear(year);
        indexGfVo.setMonth(month);
        indexGfVo.setDay(day);
        indexGfVo.setType(indexGfVo.getType());
        indexGfVo.setEnergyId(indexGfVo.getId());
        Integer cxjr=0;
        if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
            cxjr=1;
        }

        List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20111(indexGfVo);
        for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
            NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
            Integer v1 = nengKongDataDay.getV();
            Integer m1 = nengKongDataDay.getMinuteNumber();
            if (i<nengKongDataDays.size()-1){
                NengKongDataDay n2 = nengKongDataDays.get(i+1);
                Integer v2 = n2.getV();
                Integer m2 = n2.getMinuteNumber();
                Integer a=0;
                while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                    if (m1<10){
                        list1.add(v1+":0"+m1);
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (cxjr==1 && (v1>hour || (v1==hour && m1>minute))){
                        list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
                    }else {
                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));//

                    }
                    m1=m1+1;
                    a++;
                    if (m1==60){
                        m1=0;
                        v1++;
                    }
                }
                if (a==0){
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }else {

                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
                    }

                }

            }else {
                if (m1<10){
                    if (m1>0 && m1<5){
                        list1.add(v1+":00");
                    }else {
                        list1.add(v1+":0"+m1);
                    }
                }else {
                    list1.add(v1+":"+m1);
                }
                if (i!=0){
                    NengKongDataDay na = nengKongDataDays.get(i-1);
                    BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                    list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                }else {

                    list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
                }

            }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
        }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {

//            System.out.println(list1.get(i)+"--"+list2.get(i));
            if (i%5!=0){
                continue;
            }
            BigDecimal value = list2.get(i);
            if (i==0){
                value=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);//value.divide(new BigDecimal(5*60),2);
            }else {
                BigDecimal value1 = list2.get(i-5);
                BigDecimal subtract =value;// value.subtract(value1);
                subtract=subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract;
//                subtract=subtract.divide(new BigDecimal(1000),2);
                value=subtract;
//                value=subtract.divide(new BigDecimal(5*60),2);
            }

            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
//                String s = list1.get(i);
//                String[] split = s.split(":");
//                int i1 = Integer.parseInt(split[0]);
//                int i2 = Integer.parseInt(split[1]);
//                Integer hour = DateTimeUtil.getHour();
//                Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());
//                if (((i1==hour && i2>minute) || (i1<hour )) && i1>8 && value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    value=null;
//                }
                if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
                    value=null;
                }
            }else {

            }

            if (year1==year && month1==month && day1==day ){
                String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00";
                Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
                if(simpleDateTime.after(DateTimeUtil.dqsj())){
                    list22.add(null);
                }else {
                    list22.add(value);
                }
            }else {
                list22.add(value);
            }
            list11.add(list1.get(i));

            A++;
        }
        map.put("list1",list11);
        map.put("list2",list22);

        return map;
    }
    @Override
    public Map<String, Object> query31(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();

        int year = DateTimeUtil.getYear(indexGfVo.getTime());
        int month = DateTimeUtil.getMonth(indexGfVo.getTime());
        int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
        indexGfVo.setYear(year);
        indexGfVo.setMonth(month);
        indexGfVo.setDay(day);
        indexGfVo.setType(indexGfVo.getType());
        if (year1==year && month1==month && day1==day ){
            indexGfVo.setCxjr(1);
        }

        List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20111(indexGfVo);
        for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
            NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
            Integer v1 = nengKongDataDay.getV();
            Integer m1 = nengKongDataDay.getMinuteNumber();
            if (i<nengKongDataDays.size()-1){
                NengKongDataDay n2 = nengKongDataDays.get(i+1);
                Integer v2 = n2.getV();
                Integer m2 = n2.getMinuteNumber();
                Integer a=0;
                while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                    if (m1<10){
                        list1.add(v1+":0"+m1);
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    m1=m1+1;
//                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));//
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }
                    a++;
                    if (m1==60){
                        m1=0;
                        v1++;
                    }
                }
                if (a==0){
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }

                }

            }else {
                if (m1<10){
                    if (m1>0 && m1<5){
                        list1.add(v1+":00");
                    }else {
                        list1.add(v1+":0"+m1);
                    }
                }else {
                    list1.add(v1+":"+m1);
                }
                if (i!=0){
                    NengKongDataDay na = nengKongDataDays.get(i-1);
                    BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                    list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                }

            }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
//                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
        }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {
            if (i%5!=0){
                continue;
            }
            BigDecimal value = list2.get(i);
//            if (i==0){
//                value=value.divide(new BigDecimal(5*60),2);
//            }else {
//                BigDecimal value1 = list22.get(list22.size()-1);
//                value=value.subtract(value1).divide(new BigDecimal(5*60),2);
//            }

            list11.add(list1.get(i));
            list22.add(value);
            A++;
        }
        map.put("list1",list11);
        map.put("list2",list22);

        return map;
    }
    @Override
    public Map<String, Object> query32(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<String> list1=new ArrayList<>();
        List<BigDecimal> list2=new ArrayList<>();
        Integer hour = DateTimeUtil.getHour();
        Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());

        int year = DateTimeUtil.getYear(indexGfVo.getTime());
        int month = DateTimeUtil.getMonth(indexGfVo.getTime());
        int day = DateTimeUtil.getDay(indexGfVo.getTime());
        int year1 = DateTimeUtil.getYear();
        int month1 = DateTimeUtil.getMonth();
        int day1 = DateTimeUtil.getDay();
        indexGfVo.setYear(year);
        indexGfVo.setMonth(month);
        indexGfVo.setDay(day);
        indexGfVo.setType(indexGfVo.getType());
        indexGfVo.setEnergyId(indexGfVo.getId());
        Integer cxjr=0;
        if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
            cxjr=1;
        }

        List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20114(indexGfVo);
        if (nengKongDataDays.get(0).getMinuteNumber()!=0){
            NengKongDataDay nengKongDataDay=new NengKongDataDay();
            nengKongDataDay.setV(0);
            nengKongDataDay.setValue(new BigDecimal(0));
            nengKongDataDay.setMinuteNumber(0);
            nengKongDataDays.add(0,nengKongDataDay);
        }

        for (int i = 0; i < nengKongDataDays.size(); i++) {
//                if (i%5!=0){
//                    continue;
//                }
            NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
            Integer v1 = nengKongDataDay.getV();
            Integer m1 = nengKongDataDay.getMinuteNumber();
            if (i<nengKongDataDays.size()-1){
                NengKongDataDay n2 = nengKongDataDays.get(i+1);
                Integer v2 = n2.getV();
                Integer m2 = n2.getMinuteNumber();
                Integer a=0;
                while (v1!=v2 || m1!=m2 ){//|| (v1<v2 && m1!=60)

                    if (m1<10){
                        list1.add(v1+":0"+m1);
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (cxjr==1 && (v1>hour || (v1==hour && m1>minute))){
                        list2.add(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
                    }else {
                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));//

                    }
                    m1=m1+1;
                    a++;
                    if (m1==60){
                        m1=0;
                        v1++;
                    }
                }
                if (a==0){
                    if (m1<10){
                        if (m1>0 && m1<5){
                            list1.add(v1+":00");
                        }else {
                            list1.add(v1+":0"+m1);
                        }
                    }else {
                        list1.add(v1+":"+m1);
                    }
                    if (i!=0){
                        NengKongDataDay na = nengKongDataDays.get(i-1);
                        BigDecimal value = nengKongDataDay.getValue();
//                            BigDecimal value1 = na.getValue();
//                            value=value.subtract(value1).multiply(new BigDecimal(1000));
                        list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                    }else {

                        list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
                    }

                }

            }else {
                if (m1<10){
                    if (m1>0 && m1<5){
                        list1.add(v1+":00");
                    }else {
                        list1.add(v1+":0"+m1);
                    }
                }else {
                    list1.add(v1+":"+m1);
                }
                if (i!=0){
                    NengKongDataDay na = nengKongDataDays.get(i-1);
                    BigDecimal value = nengKongDataDay.getValue();
//                        BigDecimal value1 = na.getValue();
//                        value=value.subtract(value1).multiply(new BigDecimal(1000));
                    list2.add(value.setScale(2, BigDecimal.ROUND_HALF_UP));
                }else {

                    list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
                }

            }

//                if (nengKongDataDay.getMinuteNumber()==null){
//                    list1.add(nengKongDataDay.getV()+":00");//
//                }else {
//                    if (nengKongDataDay.getMinuteNumber()<10){
//                        if (nengKongDataDay.getMinuteNumber()>0 && nengKongDataDay.getMinuteNumber()<5){
//                            list1.add(nengKongDataDay.getV()+":00");
//                        }else {
//                            list1.add(nengKongDataDay.getV()+":0"+nengKongDataDay.getMinuteNumber());
//                        }
//                    }else {
//                        list1.add(nengKongDataDay.getV()+":"+nengKongDataDay.getMinuteNumber());
//                    }
//
//                }
//
        }

        List<Object> list11=new ArrayList<>();
        List<BigDecimal> list22=new ArrayList<>();
        int A=0;
        for (int i = 0; i < list2.size(); i++) {

//            System.out.println(list1.get(i)+"--"+list2.get(i));
            if (i%5!=0){
                continue;
            }
            BigDecimal value = list2.get(i);
            if (i==0){
                value=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);//value.divide(new BigDecimal(5*60),2);
            }else {
                BigDecimal value1 = list2.get(i-5);
                BigDecimal subtract =value;// value.subtract(value1);
                subtract=subtract.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):subtract;
//                subtract=subtract.divide(new BigDecimal(1000),2);
                value=subtract;
//                value=subtract.divide(new BigDecimal(5*60),2);
            }

            if (year1==year && month1==month && day1==day ){
//                indexGfVo.setCxjr(1);
//                String s = list1.get(i);
//                String[] split = s.split(":");
//                int i1 = Integer.parseInt(split[0]);
//                int i2 = Integer.parseInt(split[1]);
//                Integer hour = DateTimeUtil.getHour();
//                Integer minute = DateTimeUtil.getMinute(DateTimeUtil.dqsj());
//                if (((i1==hour && i2>minute) || (i1<hour )) && i1>8 && value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//                    value=null;
//                }
                if (value.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
                    value=null;
                }
            }else {

            }

            if (year1==year && month1==month && day1==day ){
                String cx=year1+"-"+month1+"-"+day1 +" "+list1.get(i)+":00";
                Date simpleDateTime = DateTimeUtil.toSimpleDateTime(cx);
                if(simpleDateTime.after(DateTimeUtil.dqsj())){
                    list22.add(null);
                }else {
                    list22.add(value);
                }
            }else {
                list22.add(value);
            }
            list11.add(list1.get(i));

            A++;
        }
        map.put("list1",list11);
        map.put("list2",list22);

        return map;
    }


    @Override
    public List<NyzfdqkDto> query4(@RequestBody IndexGfVo v) {
        List<NyzfdqkDto> list=new ArrayList<>();
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        for (int i = 0; i < energyStations.size(); i++) {
            OrganizationalStructure organizationalStructure = energyStations.get(i);
            NyzfdqkDto dto=new NyzfdqkDto();
            dto.setId(organizationalStructure.getId());
            dto.setName(organizationalStructure.getName());
            BigDecimal d = organizationalStructure.getInstalledCapacity() == null ? new BigDecimal(0) : organizationalStructure.getInstalledCapacity();
            dto.setZjrl(d.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
            NengKongDataDay n=new NengKongDataDay();
            n.setType(119);
            n.setClassifyNumber(2);
            n.setYear(DateTimeUtil.getYear());
            n.setEnergyId(organizationalStructure.getId());


            BigDecimal qxzxz = dataDayMapper.qxzxz31(n.getEnergyId(), 119,n.getYear(),n.getMonth());
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            BigDecimal qxzdz = dataDayMapper.qxzdz31(n.getEnergyId(),119,n.getYear(),n.getMonth());
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            newest = qxzdz.subtract(qxzxz);
            dto.setFdl((newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"");


            //发电功率
            BigDecimal nyzgl = dataDayMapper.nyzgl(n.getEnergyId());
            if (nyzgl==null){
                nyzgl=new BigDecimal(0.00);
            }
            dto.setFdgl(nyzgl.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");


            dto.setDataPhoto(organizationalStructure.getDataPhoto());
            dto.setSitePhoto(organizationalStructure.getSitePhoto());

            v.setEnergyId(organizationalStructure.getId());
            v.setType(v.getTypeNumber());
            Map<String, Object> cxlj = cxlj(v);

            dto.setSwdl(new BigDecimal(cxlj.get("a3").toString()).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            dto.setFdl(new BigDecimal(cxlj.get("a1").toString()).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            BigDecimal bigDecimal = new BigDecimal(cxlj.get("a1").toString());
            if (d.compareTo(new BigDecimal(0))==0){
                dto.setYxxss("0");
            }else {
                dto.setYxxss(bigDecimal.divide(d,2).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }

            list.add(dto);
        }
        return list;
    }

    @Override
    public Map<String, Object> cxlj(IndexGfVo indexGfVo) {
        int year = DateTimeUtil.getYear();
        int month = DateTimeUtil.getMonth();
        int day = DateTimeUtil.getDay();
        if (indexGfVo.getType()==1){
            String s = year + "-" + month +"-" + day;
            indexGfVo.setStartTime(s+" 00:00:00");
            indexGfVo.setEndTime(s+" 23:59:59");
        }else if (indexGfVo.getType()==2){
            String s1 = year + "-" + month + "-01";

            String s2 = year + "-" + (month+1) + "-01";
            if (month==12){
                s2 = year-1 + "-" + "01" + "-01";
            }
            indexGfVo.setStartTime(s1+" 00:00:00");
            indexGfVo.setEndTime(s2+" 00:00:00");
        } else if (indexGfVo.getType()==3) {
            String s1 = year + "-" + "01" + "-01";

            String s2 = year+1 + "-" + "01" + "-01";
            indexGfVo.setStartTime(s1+" 00:00:00");
            indexGfVo.setEndTime(s2+" 00:00:00");
        }else {

        }
        indexGfVo.setType(119);
        BigDecimal bigDecimal1 = dataDayMapper.cxcz1(indexGfVo);
        indexGfVo.setType(116);
        BigDecimal bigDecimal2 = dataDayMapper.cxcz1(indexGfVo);
        indexGfVo.setType(115);
        BigDecimal bigDecimal3 = dataDayMapper.cxcz1(indexGfVo);
        Map<String, Object> map=new HashMap<>();
        map.put("a1",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a2",bigDecimal2.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("a3",bigDecimal3.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        return map;
    }

    @Override
    public List<NyzfdqkDto> query5() {
        List<NyzfdqkDto> list=new ArrayList<>();
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        for (int i = 0; i < energyStations.size(); i++) {
            OrganizationalStructure organizationalStructure = energyStations.get(i);
            NyzfdqkDto dto=new NyzfdqkDto();
            dto.setId(organizationalStructure.getId());
            dto.setName(organizationalStructure.getName());
            dto.setCode(organizationalStructure.getCode());
            dto.setCreateTime(organizationalStructure.getCreateTime());



            BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
            NengKongDataDay n=new NengKongDataDay();

            //当日发电量 109-发电量（每小时）
            n.setYear(DateTimeUtil.getYear());
            n.setEnergyId(organizationalStructure.getId());
            n.setType(115);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
            BigDecimal qxzxz = dataDayMapper.qxzxz3(organizationalStructure.getId(),115, null);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            newest=newest.subtract(qxzxz);
            BigDecimal dr=newest;
            if (dr.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==-1){
                dr=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
            }


            n.setType(101);
            n.setClassifyNumber(1);
//            newest = dataDayMapper.grandTotal(n);
//            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);



            //今日
//            n.setType(109);
//            n.setClassifyNumber(2);
//            BigDecimal n2 = dataDayMapper.newest(n);
//            n2=n2==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):n2.setScale(2, BigDecimal.ROUND_HALF_UP);
            qxzxz = dataDayMapper.qxzxz1(organizationalStructure.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
            BigDecimal qxzdz = dataDayMapper.qxzdz1(organizationalStructure.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119);
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            //今日
            dto.setFdl(dr.add(qxzdz).subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//kW·h

            n.setType(101);
            n.setClassifyNumber(1);
            Long yxts = dataDayMapper.yxts(n);
            dto.setYxsj((yxts==null?0:yxts)+"");//天
            dto.setScwb(DateTimeUtil.getStrDateTime3(organizationalStructure.getScwb()));

            BigDecimal fdl = dataDayMapper.cxcz(organizationalStructure.getCode(),"production", "发电量总");
            BigDecimal swdl = dataDayMapper.cxcz(organizationalStructure.getCode(),"up", "上网电量总");
            fdl=fdl==null?new BigDecimal(0):fdl;
            swdl=swdl==null?new BigDecimal(0):swdl;

            String dbyxzt="";
            if (swdl.compareTo(new BigDecimal(0))==0 && fdl.compareTo(new BigDecimal(0))!=0){
                dbyxzt="全额消纳";
            }else if (swdl.compareTo(new BigDecimal(0))==0 && fdl.compareTo(new BigDecimal(0))==0){
                dbyxzt="暂停运行";
            }else if (swdl.compareTo(new BigDecimal(0))!=0 && fdl.compareTo(swdl)==0){
                dbyxzt="全额上网";
            }else if (swdl.compareTo(fdl)==-1){
                dbyxzt="部分消纳";
            }

            dto.setDbyxzt(dbyxzt);
            list.add(dto);
        }
        return list;
    }
    @Override
    public Map<String, Object> query6(IndexGfVo indexGfVo) {
        Map<String, Object> map=new HashMap<>();
        List<Object> list1=new ArrayList<>();
        List<Object> list2=new ArrayList<>();
        if (indexGfVo.getTypeNumber()==1){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            int day = DateTimeUtil.getDay();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setDay(day);
            indexGfVo.setType(indexGfVo.getType()+3);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query20(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else if (indexGfVo.getTypeNumber()==2){
            int year = DateTimeUtil.getYear();
            int month = DateTimeUtil.getMonth();
            indexGfVo.setYear(year);
            indexGfVo.setMonth(month);
            indexGfVo.setType(indexGfVo.getType());
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query21(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());
                if (nengKongDataDay.getV().equals(String.valueOf(DateTimeUtil.getDay()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(indexGfVo.getType()+3);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest));
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }else {
            int year = DateTimeUtil.getYear();
            indexGfVo.setYear(year);
            indexGfVo.setType(indexGfVo.getType());
            indexGfVo.setType(115);
            List<NengKongDataDay> nengKongDataDays = dataDayMapper.query22(indexGfVo);
            for (int i = 0; i < nengKongDataDays.size(); i++) {
                NengKongDataDay nengKongDataDay = nengKongDataDays.get(i);
                list1.add(nengKongDataDay.getV());

                if (nengKongDataDay.getV().equals(String.valueOf(DateTimeUtil.getMonth()))){
                    NengKongDataDay n=new NengKongDataDay();
                    n.setTimeStr(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
                    BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
                    n.setType(indexGfVo.getType()+3);
                    n.setClassifyNumber(2);
                    newest = dataDayMapper.newest(n);
                    nengKongDataDay.setValue(nengKongDataDay.getValue().add(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest));
                }
                list2.add(nengKongDataDay.getValue().setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            map.put("list1",list1);
            map.put("list2",list2);
            map.put("list3",list2);
        }
        return map;
    }
    @Override
    public Map<String, Object> nyzQuery1(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        Map<String, Object> map=new HashMap<>();
        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);
        n.setTime(DateTimeUtil.toSimpleDate(DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj())));
        //发电功率 107
        n.setType(107);
        n.setClassifyNumber(2);
        newest = dataDayMapper.qxdqgl(null);//dataDayMapper.newest(n);
        map.put("a1",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"");//发电功率+"kw·h"

        //108-辐照强度（每小时）
        n.setType(108);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        map.put("a2",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP))+"");//辐照强度+"kwh/m²"

        //110-温度
        n.setType(110);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        map.put("a3",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.doubleValue())+"");//温度+"℃"

        //111-湿度
        n.setType(111);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        map.put("a4",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.doubleValue())+"");//湿度+"%"

        //有效小时
        BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;

        BigDecimal qxzdz = dataDayMapper.qxzdz1(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),115);
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        BigDecimal subtract = qxzdz.subtract(qxzxz);
        OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
        if (organizationalStructure==null){
            map.put("a5",0);
        }else {
            BigDecimal installedCapacity = organizationalStructure.getInstalledCapacity();
            if (installedCapacity==null){
                map.put("a5",0);
            }else {
                map.put("a5",subtract.divide(installedCapacity,2).setScale(2, BigDecimal.ROUND_HALF_UP));
            }

        }

//        n.setType(104);
//        n.setYear(DateTimeUtil.getYear());
//        n.setClassifyNumber(1);
//        n.setEnergyId(n.getId());
//        Long yxts = dataDayMapper.yxts(n);
//        Long A1=yxts==null?0l:yxts;
//        Long jrxss = dataDayMapper.jrxss(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
//        jrxss=jrxss==null?0:jrxss;
//        map.put("a5",A1+jrxss);//有效小时+"h"
        return map;
    }

    @Override
    public Map<String, Object> nyzQuery4(NengKongDataDay n) {
        Map<String, Object> map=new HashMap<>();
        if (n.getId()!=null){
            n.setEnergyId(n.getId());
            BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);

            //有效小时
            BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
            qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;

            BigDecimal qxzdz = dataDayMapper.qxzdz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
            qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
            BigDecimal subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
            map.put("dr",subtract.setScale(2, BigDecimal.ROUND_HALF_UP)+"");

            if (DateTimeUtil.getStrDateTime3(n.getTime()).compareTo(DateTimeUtil.getStrDateTime3(new Date()))==0){
                qxzdz = dataDayMapper.qxzdz11(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),161);
                qxzdz=qxzdz==null?new BigDecimal(0.00):qxzdz;
                map.put("dxxss",qxzdz.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }else {
                qxzdz = dataDayMapper.qxzdz11(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),160);
                qxzdz=qxzdz==null?new BigDecimal(0.00):qxzdz;
                map.put("dxxss",qxzdz.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }
            OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
            BigDecimal installedCapacity = organizationalStructure.getInstalledCapacity();
            installedCapacity=installedCapacity==null?new BigDecimal(0):installedCapacity;
            if (installedCapacity==null){
                map.put("dxxss",0+"");
            }else {
                map.put("dxxss",subtract.divide(installedCapacity,2).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }


        }else {
            QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("examine",1);
            queryWrapper.eq("type",6);
            List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
            BigDecimal aaa=new BigDecimal(0);
            BigDecimal dxxss=new BigDecimal(0);
            BigDecimal installedCapacity=new BigDecimal(0);
            for (int i = 0; i < energyStations.size(); i++) {
                OrganizationalStructure organizationalStructure = energyStations.get(i);
                n.setId(organizationalStructure.getId());
                BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);

                //有效小时
                BigDecimal qxzxz = dataDayMapper.qxzxz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
                qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;

                BigDecimal qxzdz = dataDayMapper.qxzdz1(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),119);
                qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
                BigDecimal subtract = qxzdz.subtract(qxzxz).setScale(2, BigDecimal.ROUND_HALF_UP);
                aaa=aaa.add(subtract);

                if (DateTimeUtil.getStrDateTime3(n.getTime()).compareTo(DateTimeUtil.getStrDateTime3(new Date()))==0){
                    qxzdz = dataDayMapper.qxzdz11(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),161);
                    qxzdz=qxzdz==null?new BigDecimal(0.00):qxzdz;
                    dxxss=dxxss.add(qxzdz);
                }else {
                    qxzdz = dataDayMapper.qxzdz11(n.getId(), DateTimeUtil.getStrDateTime3(n.getTime()),160);
                    qxzdz=qxzdz==null?new BigDecimal(0.00):qxzdz;
                    dxxss=dxxss.add(qxzdz);
                }
                BigDecimal installedCapacity1 = organizationalStructure.getInstalledCapacity();
                installedCapacity1=installedCapacity1==null?new BigDecimal(0):installedCapacity1;
                installedCapacity=installedCapacity.add(installedCapacity1);

            }
            map.put("dr",aaa.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
//            map.put("dxxss",dxxss.setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            if (installedCapacity==null){
                map.put("dxxss",0+"");
            }else {
                map.put("dxxss",aaa.divide(installedCapacity,2).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }

        }
        return map;
    }
    @Override
    public Map<String, Object> nyzQuery5(NengKongDataDay n) {
        Map<String, Object> map=new HashMap<>();

        BigDecimal nyzgl = dataDayMapper.nyzgl(n.getId());
        if (nyzgl==null){
            nyzgl=new BigDecimal(0.00);
        }
        map.put("s2",nyzgl.setScale(2, BigDecimal.ROUND_HALF_UP)+"");

        OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
        if (organizationalStructure.getInstalledCapacity()==null){
            organizationalStructure.setInstalledCapacity(new BigDecimal(0.00));
        }
        map.put("s3",organizationalStructure.getInstalledCapacity().setScale(2, BigDecimal.ROUND_HALF_UP)+"");

        if (organizationalStructure.getInstalledCapacity().compareTo(new BigDecimal(0))!=0){
            map.put("s1",nyzgl.divide(organizationalStructure.getInstalledCapacity(),2).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        }else{
            map.put("s1",new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        }
        if (organizationalStructure.getIlluminance()==null){
            organizationalStructure.setIlluminance(new BigDecimal(0.00));
        }
        if (organizationalStructure.getTemperature()==null){
            organizationalStructure.setTemperature(new BigDecimal(0.00));
        }
        if (organizationalStructure.getHumidity()==null){
            organizationalStructure.setHumidity(new BigDecimal(0.00));
        }
        if (organizationalStructure.getIrradiation()==null){
            organizationalStructure.setIrradiation(new BigDecimal(0.00));
        }
        if (organizationalStructure.getPm25()==null){
            organizationalStructure.setPm25(new BigDecimal(0.00));
        }
        if (organizationalStructure.getPm10()==null){
            organizationalStructure.setPm10(new BigDecimal(0.00));
        }

        map.put("s4",organizationalStructure.getIlluminance().setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("s5",organizationalStructure.getTemperature().setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("s6",organizationalStructure.getHumidity().setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("s7",organizationalStructure.getIrradiation().setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("s8",organizationalStructure.getPm25().setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        map.put("s9",organizationalStructure.getPm10().setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        return map;
    }
    @Override
    public Map<String, Object> nyzQuery2(NengKongDataDay n) {
        n.setEnergyId(n.getId());
        Map<String, Object> map=new HashMap<>();
        map.put("a1","0.00");//发电量+"万Kwh"
        map.put("a2","0.00");//系统效率+"%"
        map.put("a3","0.00");//总装机+"kWp"
        map.put("a4","0.00");//节煤量+"t"
        map.put("a5","0.00");//碳减排量+"t"
        map.put("a6","0");//运行天数+"t"

        BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);

        //当日发电量 109-发电量（每小时）
        n.setType(115);
        n.setClassifyNumber(2);
        newest = dataDayMapper.newest(n);
        newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest.setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal qxzxz = dataDayMapper.qxzxz(n.getId(), DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()));
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        newest=newest.subtract(qxzxz);
        BigDecimal dr=newest;
        map.put("a109",newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//kWh

        qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,n.getYear(),n.getMonth());
        qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
        BigDecimal qxzdz = dataDayMapper.qxzdz31(n.getId(),119,n.getYear(),n.getMonth());
        qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
        BigDecimal bigDecimal1 = qxzdz.subtract(qxzxz);
        map.put("a1",bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"kW·h" .divide(new BigDecimal(10000)

        //总装机
        newest=organizationalStructureService.mfxss(n.getId());
        n.setType(102);
        n.setClassifyNumber(1);
//        newest = dataDayMapper.zj(n);
        map.put("a3",(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP):newest.divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_UP))+"");

//        QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
//        queryWrapper22.eq("year",n.getYear());
//        CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
//        if(coefficientYear==null){
//            coefficientYear=new CoefficientYear();
//            coefficientYear.setCoefficient2(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//            coefficientYear.setCoefficient1(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
//        }
//        //节煤炭量
//        map.put("a4",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        //碳减排量
//        map.put("a5",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
//        map.put("a107",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000*18.3*40),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"


        if(n.getYear()==null){

            QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
            queryWrapper22.ge("year",2024);
            List<CoefficientYear> coefficientYears = coefficientYearMapper.selectList(queryWrapper22);
            bigDecimal1=new BigDecimal(0);
            BigDecimal bigDecimal2=new BigDecimal(0);
            for (int i = 0; i < coefficientYears.size(); i++) {
                CoefficientYear coefficientYear1 = coefficientYears.get(i);
                qxzxz = dataDayMapper.qxzxz31(n.getId(), 119,coefficientYear1.getYear(),n.getMonth());
                qxzxz=qxzxz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz;
                qxzdz = dataDayMapper.qxzdz31(n.getId(),119,coefficientYear1.getYear(),n.getMonth());
                qxzdz=qxzdz==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz;
                bigDecimal1 = bigDecimal1.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient1()));
                bigDecimal2 = bigDecimal2.add(qxzdz.subtract(qxzxz).multiply(coefficientYear1.getCoefficient2()));
            }


            //节煤炭量
            map.put("a4",bigDecimal1.divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a5",bigDecimal2.divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a107",bigDecimal2.divide(new BigDecimal(1000*18.3*40),0, RoundingMode.UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }else {
            QueryWrapper<CoefficientYear> queryWrapper22=new QueryWrapper<>();
            queryWrapper22.eq("year",n.getYear());
            CoefficientYear coefficientYear = coefficientYearMapper.selectOne(queryWrapper22);
            //节煤炭量
            map.put("a4",bigDecimal1.multiply(coefficientYear.getCoefficient1()).divide(new BigDecimal(1000*1000)).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //碳减排量
            map.put("a5",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*1000),3, RoundingMode.HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//+"t"
            //植树
            map.put("a107",bigDecimal1.multiply(coefficientYear.getCoefficient2()).divide(new BigDecimal(1000*18.3*40),0, RoundingMode.HALF_UP).setScale(0, BigDecimal.ROUND_HALF_UP)+"");//+"t"

        }



        //系统效率
        OrganizationalStructure organizationalStructure = organizationalStructureMapper.selectById(n.getId());
        if (organizationalStructure==null || organizationalStructure.getInstalledKw5()==null || organizationalStructure.getInstalledKw5().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
            map.put("a2",new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
        }else {
            if (organizationalStructure==null || organizationalStructure.getInstalledKw51()==null || organizationalStructure.getInstalledKw51().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))<1){
                map.put("a2",new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }else {
                map.put("a2",(organizationalStructure.getInstalledKw51().divide(organizationalStructure.getInstalledKw5(),2).multiply(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP)+"");
            }

        }
//        BigDecimal qxdqgl = dataDayMapper.qxdqgl(n.getId());
//        BigDecimal qxdqgl1 = dataDayMapper.qxdqgl1(n.getId());
//        if (qxdqgl1.compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))==0){
//            map.put("a2",0);
//        }else {
//            map.put("a2",qxdqgl.divide(qxdqgl1,2).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP));
//        }

        long daysBetweenDates = DateTimeUtil.getDaysBetweenDates(organizationalStructure.getCreateTime(), new Date());
        map.put("a6",daysBetweenDates);//运行天数+"t"
        return map;
    }

    @Override
    public List<Map<String,Object>> nyzQuery3(NengKongDataDay n) {
        System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));
        List<Map<String,Object>> list=new ArrayList<>();
        QueryWrapper<EquipmentManagement> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("site_id",n.getId());
        queryWrapper.eq("examine",1);
        if (n.getEquipmentType()==6){
            queryWrapper.in("equipment_type",6,7);
            queryWrapper.notIn("name","虚拟电表");
        }else {
            queryWrapper.eq("equipment_type",n.getEquipmentType());
        }

        List<EquipmentManagement> energyMacs = equipmentManagementMapper.selectList(queryWrapper);
        for (int i = 0; i < energyMacs.size(); i++) {
            EquipmentManagement equipmentManagement = energyMacs.get(i);
            n.setMacId(equipmentManagement.getId());
            BigDecimal newest=new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP);


            System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));
            Map<String,Object> map=new HashMap<>();
            map.put("macId",equipmentManagement.getId());
            map.put("macName",equipmentManagement.getName());
            map.put("code",equipmentManagement.getSn());
            map.put("rateOfWork",equipmentManagement.getRateOfWork()==null?0:equipmentManagement.getRateOfWork().divide(new BigDecimal(1),2).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//kW
//            map.put("temperature",equipmentManagement.getTemperature()==null?0:equipmentManagement.getTemperature().doubleValue()+"℃");
//            map.put("humidity",equipmentManagement.getHumidity()==null?0:equipmentManagement.getHumidity().doubleValue()+"%");
            if (equipmentManagement.getRateOfWorkDc()==null || equipmentManagement.getRateOfWorkDc().compareTo(new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP))!=1){
                map.put("efficiency",new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//%
            }else {
                map.put("efficiency",equipmentManagement.getRateOfWork().multiply(new BigDecimal(100)).divide(equipmentManagement.getRateOfWorkDc(),2).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//%
            }

            map.put("operationState",(equipmentManagement.getOperationState()==null || equipmentManagement.getOperationState()!=0)?"离网":"并网");


            System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));
            //110-温度
            n.setType(110);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            map.put("temperature",newest==null?0:newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//℃
//            energyMac.setTemperature((newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest));//温度
//
//            //111-湿度
            n.setType(111);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            map.put("humidity",newest==null?0:newest.setScale(2, BigDecimal.ROUND_HALF_UP)+"");//%
//            energyMac.setTemperature(newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest);//湿度

            System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));
            //设备上网电量
//            n.setType(151);
//            n.setClassifyNumber(2);
//            newest = dataDayMapper.newest(n);
//            BigDecimal minimum = dataDayMapper.minimum(n);
//            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
//            minimum=minimum==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):minimum;
//            map.put("sbswdl",newest.subtract(minimum).doubleValue()+"");//kw
            //设备下网网电量
//            n.setType(153);
//            n.setClassifyNumber(2);
//            newest = dataDayMapper.newest(n);
//            minimum = dataDayMapper.minimum(n);
//            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
//            minimum=minimum==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):minimum;
//            map.put("sbxwdl",newest.subtract(minimum).doubleValue()+"");//kw


            //当日发电量
            n.setType(119);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            BigDecimal minimum = dataDayMapper.qxzxz122(n.getId(),n.getMacId(),DateTimeUtil.getStrDateTime3(new Date()),119);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
            minimum=minimum==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):minimum;
            map.put("drfdl",newest.subtract(minimum).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//kw

            System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));
            //累计发电量
            n.setType(119);
            n.setClassifyNumber(2);
            newest = dataDayMapper.newest(n);
            minimum = dataDayMapper.minimum(n);
            newest=newest==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):newest;
            minimum=minimum==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):minimum;
            map.put("ljfdl",newest.subtract(minimum).setScale(2, BigDecimal.ROUND_HALF_UP)+"");//kw
            //
            map.put("jld","无");
            if (equipmentManagement.getEdgl()==null){
                equipmentManagement.setEdgl(new BigDecimal(0.00));
            }
            map.put("edgl",equipmentManagement.getEdgl().setScale(2, BigDecimal.ROUND_HALF_UP)+"");

            System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));

            map.put("total",equipmentManagement.getTotal());
            map.put("tip",equipmentManagement.getTip());
            map.put("peak",equipmentManagement.getPeak());
            map.put("normal",equipmentManagement.getNormal());
            map.put("valley",equipmentManagement.getValley());


            map.put("retotal",equipmentManagement.getReTotal());
            map.put("retip",equipmentManagement.getReTip());
            map.put("repeak",equipmentManagement.getRePeak());
            map.put("renormal",equipmentManagement.getReNormal());
            map.put("revalley",equipmentManagement.getReValley());
            list.add(map);
        }
        if (!list.isEmpty()){
            ArrayList<Map<String, Object>> list1 = new ArrayList<>();
            ArrayList<Map<String, Object>> list2 = new ArrayList<>();
            for (Map<String, Object> stringObjectMap : list) {
                if (stringObjectMap.get("operationState").equals("并网"))
                    list1.add(stringObjectMap);
                if (stringObjectMap.get("operationState").equals("离网"))
                    list2.add(stringObjectMap);
            }
            if (!list2.isEmpty()){
                for (Map<String, Object> stringObjectMap : list2) {
                    list1.add(stringObjectMap);
                }
            }
            return list1;
        }
        return list;
    }


    @Override
    public Map<String,Object> nyzQuery31(NengKongDataDay n) {
        Map<String,Object> map=new HashMap<>();
        System.out.println("时间："+DateTimeUtil.getStrDateTime(new Date()));
        List<Map<String,Object>> list=new ArrayList<>();
        QueryWrapper<EquipmentManagement> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("site_id",n.getId());
        queryWrapper.eq("examine",1);
        queryWrapper.eq("equipment_type",5);

        List<EquipmentManagement> energyMacs = equipmentManagementMapper.selectList(queryWrapper);
        for (int i = 0; i < energyMacs.size(); i++) {
            EquipmentManagement equipmentManagement = energyMacs.get(i);

//            BigDecimal qxzxz19 = dataDayMapper.qxzdz191(equipmentManagement.getSiteId(),equipmentManagement.getId(),DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119,DateTimeUtil.getHour()-1);
//            qxzxz19=qxzxz19==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzxz19;
//            BigDecimal qxzdz19 = dataDayMapper.qxzdz191(equipmentManagement.getSiteId(),equipmentManagement.getId(),DateTimeUtil.getStrDateTime3(DateTimeUtil.dqsj()),119,DateTimeUtil.getHour());
//            qxzdz19=qxzdz19==null?new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP):qxzdz19;
//            map.put("a"+i+1,qxzdz19.subtract(qxzxz19).setScale(2, BigDecimal.ROUND_HALF_UP));

            if (equipmentManagement.getRateOfWork()==null){
                equipmentManagement.setRateOfWork(new BigDecimal(0));
            }
            map.put("a"+i+1,equipmentManagement.getRateOfWork().setScale(2, BigDecimal.ROUND_HALF_UP));
        }

        QueryWrapper<EquipmentManagement> queryWrapper2=new QueryWrapper<>();
        queryWrapper2.eq("site_id",n.getId());
        queryWrapper2.eq("examine",1);
        queryWrapper2.eq("name","虚拟电表");

        List<EquipmentManagement> energyMacs2 = equipmentManagementMapper.selectList(queryWrapper2);
        for (int i = 0; i < energyMacs2.size(); i++) {
            EquipmentManagement equipmentManagement = energyMacs2.get(i);
            if (equipmentManagement.getSn().equals("production")){

                BigDecimal fd = dataDayMapper.qxzdz3(n.getId(), 119, null);
                map.put("b2",fd.setScale(2, BigDecimal.ROUND_HALF_UP));//发电
            }else if (equipmentManagement.getSn().equals("up")){
                BigDecimal sw = dataDayMapper.qxzdz3(n.getId(), 115, null);
                map.put("b1",sw.setScale(2, BigDecimal.ROUND_HALF_UP));//上网
            }else if (equipmentManagement.getSn().equals("down")){
                BigDecimal xiawang = dataDayMapper.qxzdz3(n.getId(), 117, null);
                map.put("b3",xiawang.setScale(2, BigDecimal.ROUND_HALF_UP));//下网
            }else if (equipmentManagement.getSn().equals("local")){
                BigDecimal xiaowang = dataDayMapper.qxzdz3(n.getId(), 116, null);
                map.put("b4",xiaowang.setScale(2, BigDecimal.ROUND_HALF_UP));//消网
            }
        }

        return  map;
    }
    @Override
    public Page<OpsTicketsMessage> gd(PageVo val) {
        //查找工单信息
        Page<OpsTicketsMessage> page = new Page<OpsTicketsMessage>(val.getPage(), val.getSize());
        QueryWrapper<OpsTicketsMessage> wrapper = new QueryWrapper<>();
//        wrapper.eq(ObjectUtils.isNotNull(val.getEnergyId()),"energy_id",val.getEnergyId());
        wrapper.eq(ObjectUtils.isNotNull(val.getState()),"state",val.getState());
        wrapper.like(ObjectUtils.isNotNull(val.getLike()),"name",val.getLike());
        wrapper.ge(ObjectUtils.isNotNull(val.getBeginTime()),"create_time",val.getBeginTime());
        wrapper.le(ObjectUtils.isNotNull(val.getOverTime()),"create_time",val.getOverTime());
        wrapper.orderByDesc("create_time");
        opsTicketsMessageMapper.selectPage(page, wrapper);

        return page;
    }

    @Override
    public List<OrganizationalStructure> wzxx() {
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("examine",1);
        queryWrapper.eq("type",6);
        List<OrganizationalStructure> energyStations = organizationalStructureMapper.selectList(queryWrapper);
        return energyStations;
    }

    @Override
    public List<Map<String, Object>> jkdz(Long id) {
        List<Map<String, Object>> list=new ArrayList<>();
        QueryWrapper<VideoSurveillance> queryWrapper=new QueryWrapper<>();
        if (id==-1){
            queryWrapper.isNull("energy_id");
        }else {
            queryWrapper.eq("energy_id",id);
        }
        List<VideoSurveillance> videoSurveillances = videoSurveillanceMapper.selectList(queryWrapper);
        for (int i = 0; i <videoSurveillances.size(); i++) {
            Map<String, Object> map=new HashMap<>();
            VideoSurveillance videoSurveillance = videoSurveillances.get(i);
            map.put("accessToken",videoSurveillance.getAccessToken());
            map.put("img",videoSurveillance.getImg());
//            map.put("password",videoSurveillance.getPassword());
            Map<String, Object> m=new HashMap<>();
            m.put("accessToken",videoSurveillance.getAccessToken());
            m.put("deviceSerial",videoSurveillance.getDeviceSerial());
            m.put("channelNo",videoSurveillance.getChannelNo());
            m.put("code",videoSurveillance.getPassword());
            String url="https://open.ys7.com/api/lapp/v2/live/address/get";
            String s = doPostForm(url, m);
            if (s.equals("")){
                map.put("url",null);
            }else {
                JSONObject jsonObject = JSON.parseObject(s);
                if (jsonObject.getString("code").equals("200")){
                    String string = jsonObject.getJSONObject("data").getString("url");
                    map.put("url",string);
                }else {
                    map.put("url",null);
                    map.put("msg","萤石云返回错误："+jsonObject.getString("msg"));
                }
            }
            list.add(map);
        }
        return list;
    }
    @Override
    public List<EquipmentManagement> jkdz1(Long id) {
        //List<Object> list=new ArrayList<>();
        List<EquipmentManagement> equipment = new ArrayList<>();
        QueryWrapper<OrganizationalStructure> queryWrapper=new QueryWrapper<>();
        //queryWrapper.isNotNull("jkdz");
        if (id!=null){
            queryWrapper.eq("id",id);
        }else {
            queryWrapper.eq("examine",1);
            queryWrapper.eq("type",6);
        }
        List<OrganizationalStructure> organizationalStructures = organizationalStructureMapper.selectList(queryWrapper);
        for (int i = 0; i < organizationalStructures.size(); i++) {
            OrganizationalStructure organizationalStructure = organizationalStructures.get(i);
            List<EquipmentManagement> equipmentManagements = equipmentManagementMapper.selectList(new QueryWrapper<EquipmentManagement>()
                    .eq("site_id", organizationalStructure.getId())
                    .eq("equipment_type",11).eq("examine",1).isNull("delete_examine"));
            if (!equipmentManagements.isEmpty()){
                for (EquipmentManagement equipmentManagement : equipmentManagements) {
                    equipment.add(equipmentManagement);
                }
            }
            //list.add(equipmentManagements);
            //list.add(organizationalStructure.getJkdz());
        }
        return  equipment;
    }
    @Override
    public List<Map<String, Object>> sxnyz() {
        List<Map<String, Object>> sxnyz = organizationalStructureMapper.sxnyz();
        return sxnyz;
    }

    @Override
    public List<OrganizationalStructure> sxnyz1(Long id) {
        List<OrganizationalStructure> sxnyz = organizationalStructureMapper.sxnyz1(id);
        return sxnyz;
    }
    /**
     * form表单提交
     * @param url
     * @param map
     * @return
     */
    public static String doPostForm(String url, Map<String, Object> map) {
        String strResult = "";
        // 1. 获取默认的client实例
        CloseableHttpClient client = HttpClients.createDefault();
        // 2. 创建httppost实例
        HttpPost httpPost = new HttpPost(url);
        httpPost.setHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
        // 3. 创建参数队列（键值对列表）
        List<NameValuePair> paramPairs = new ArrayList<>();
        Set<String> keySet = map.keySet();
        for (String key : keySet) {
            Object val = map.get(key);
            paramPairs.add(new BasicNameValuePair(key, val.toString()));
        }
        UrlEncodedFormEntity entity;
        try {
            // 4. 将参数设置到entity对象中
            entity = new UrlEncodedFormEntity(paramPairs, "UTF-8");
            System.out.println("封装的参数："+entity);
            // 5. 将entity对象设置到httppost对象中
            httpPost.setEntity(entity);
            // 6. 发送请求并回去响应
            CloseableHttpResponse resp = client.execute(httpPost);
            try {
                // 7. 获取响应entity
                HttpEntity respEntity = resp.getEntity();
                strResult = EntityUtils.toString(respEntity, "UTF-8");
            } finally {
                // 9. 关闭响应对象
                resp.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 10. 关闭连接，释放资源
            try {
                client.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return strResult;
    }
}
